feat(telegram): first-class [telegram] config section#1265
Conversation
Implements #1263 for Telegram: every TELEGRAM_* env var now has a [telegram] config field. Config-authoritative with ${} expansion and TELEGRAM_* env fallback when a field is unset (matches [discord]/[slack]). - TelegramConfig + resolve() in openab-core (config > env > default) - AppState gains telegram_streaming + apply_telegram_config() (plain params, no core dependency) - unified_adapter reads resolved streaming instead of env directly - main.rs applies resolved config + webhook_path to the embedded gateway - backward compatible: env-only deployments (no [telegram]) unchanged Refs #1263
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…egramConfig param object
- Filter empty strings in TelegramConfig::resolve() so ${UNSET_VAR}
expansion to "" correctly falls through to TELEGRAM_* env fallback
instead of holding Some("") that bypasses the fallback chain.
- Replace 5-param apply_telegram_config() with GatewayTelegramConfig
parameter object for a clean, extensible cross-crate API boundary.
- Add test: telegram_empty_string_falls_through_to_env
This comment has been minimized.
This comment has been minimized.
…ting tests - Startup validation now recognizes [telegram] section as a valid adapter config (no longer requires TELEGRAM_BOT_TOKEN env var). - Unified server spawn condition also triggers on cfg.telegram.is_some(), so config-only deployments work as promised by the PR. - Merge empty-string test into the single serialized telegram_env_fallback_and_defaults test to eliminate env var race conditions under parallel test execution.
This comment has been minimized.
This comment has been minimized.
…test Merge telegram_config_value_wins_over_env into telegram_resolve_all_scenarios (renamed from telegram_env_fallback_and_defaults) to eliminate any possible env var race condition under parallel test execution. All TELEGRAM_* env mutations are now in one #[test] function.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
LGTM ✅ — First-class What This PR DoesAdds a first-class Minimal required config: [telegram]
bot_token = "${TELEGRAM_BOT_TOKEN}" # or use aws-sm:// secret refHow It Works
Findings
What's Good (🟢)
Review HistoryThis review incorporates findings from 3 rounds of team review: Round 1 — identified empty-string All 🔴 and 🟡 findings have been addressed in follow-up commits on this branch. Baseline Check
|
Implements the first-class per-platform config ADR (#1263) for Telegram: every
TELEGRAM_*env var now has a corresponding field under a top-level[telegram]section, symmetric with[discord]/[slack].Precedence (per field)
[telegram]value (with${}expansion) →TELEGRAM_*env var → built-in default.Config-authoritative, matching OpenAB's existing
[discord]/[slack]convention. Backward compatible — env-only deployments (no[telegram]section) are unchanged; any omitted field falls back to its env var.Field mapping
[telegram]fieldbot_tokenTELEGRAM_BOT_TOKENsecret_tokenTELEGRAM_SECRET_TOKENtrusted_source_onlyTELEGRAM_TRUSTED_SOURCE_ONLYfalserich_messagesTELEGRAM_RICH_MESSAGEStruestreamingTELEGRAM_STREAMINGrich_messageswebhook_pathTELEGRAM_WEBHOOK_PATH/webhook/telegramChanges
openab-core/config.rs:TelegramConfig+resolve()(config > env > default),telegramfield onConfigopenab-gateway/lib.rs:AppState.telegram_streamingfield +apply_telegram_config()(plain params — no core dependency); bothfrom_envandserve()initializers readTELEGRAM_STREAMINGunified_adapter.rs:use_streaming()reads the resolved field instead ofstd::env::varat runtimemain.rs: embedded gateway applies resolved[telegram]config + webhook pathdocs/telegram.md+config.toml.exampleScope
Covers the
TELEGRAM_*transport/platform vars (this issue's ask). Per-platform trust fields (allowed_users,allow_dm, …) land with the identity-trust-none work (#1264).Testing
cargo clippy --features unified -D warningscleanopenab-coresuite passes (the one unrelatedsecrets::resolve_exec_nonzero_exitfailure is a pre-existing macOS-only quirk, green on Linux CI)Refs #1263